<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <base href="<?=site_url()?>"/>
<link rel="stylesheet" href="css/zepto.alert.css"/>
<script src="js/zepto.min.js"></script>
<script src="js/zepto.alert.js"></script>
<script type="text/javascript">
    //调用微信JS api 支付
    function jsApiCall()
    {
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',
            <?php echo $jsApiParameters; ?>,
            function(res){
                if(res.err_msg=='get_brand_wcpay_request:ok') {
                    $.dialog({
                        title:'温馨提示',
                        content:'<?=$suc_msg?>',
                        time:2000
                    });
                    setTimeout(function() {
                        location.href='./user/custom';
                    },3000);
                } else if(res.err_msg=='get_brand_wcpay_request:cancel') {
                    setTimeout(function() {history.back();},1000);
                }
                //alert(res.err_msg);
                WeixinJSBridge.log(res.err_msg);
            }
        );
    }

    function callpay()
    {
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        }else{
            jsApiCall();
        }
    }
    //获取共享地址
    function editAddress()
    {
        WeixinJSBridge.invoke(
            'editAddress',
            <?php echo $editAddress; ?>,
            function(res){
                var value1 = res.proviceFirstStageName;
                var value2 = res.addressCitySecondStageName;
                var value3 = res.addressCountiesThirdStageName;
                var value4 = res.addressDetailInfo;
                var tel = res.telNumber;

                //alert(value1 + value2 + value3 + value4 + ":" + tel);
            }
        );
    }

    window.onload = function(){
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', editAddress, false);
            }else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', editAddress);
                document.attachEvent('onWeixinJSBridgeReady', editAddress);
            }
        }else{
            editAddress();
        }
        callpay();
    };

</script>
</head>
</html>